$NG.AllReady(function (page, { useAction, useBeforeClick, useValuesChange, useClick, useUpdateRow, subscribe, useUpdateRows }) {
    const mstform = $NG.getCmpApi("p_form_yzhtbgsptcgl_m")
    const dgrid1 = $NG.getCmpApi("")
    const getHeadValue = (str) => mstform.getItem(str).getValue()
    hiddenQt()
    lbMFilter()
    useValuesChange(() => {
        lbMFilter()
        let label = '变更'
        const val = mstform.getItem("u_bgsj").getValue()
        switch (String(val)) {
            case '03':
                label = '调差'
                break
            case '01':
                label = "变更"
                break
            case '02':
                label = '索赔'
                break
        }
        mstform.getItem("u_bglb").setProps({
            label: label + "类别"
        })
    }, "u_bgsj")

    useValuesChange(() => {
        hiddenQt()
    }, "u_bgsptcyj")

    useValuesChange(() => {
        hiddenQt()
    }, "u_bglb")

    useValuesChange(({args})=>{
        const data = args[0]
        console.log(`args[0]`,args[0].u_htmc.origin);
        mstform.getItem("bill_no").setValue(args[0].u_htmc.origin.bill_no)
    },'p_form_yzhtbgsptcgl_m.u_htmc')

    // 其他说明字段的显示和隐藏
    function hiddenQt() {
        const lb = mstform.getItem("u_bgsptcyj").getValue()
        console.log(`lb`, lb);
        let hidden = true
        if (lb.includes('6870000000000359')) {
            hidden = false
        } else {
            hidden = true
        }

        // 变更类别
        const lb1 = [mstform.getItem("u_bglb").getValue()]
        console.log(`lb1`, lb1);
        let hidden1 = true
        if (lb1.includes('6870000000000343') || lb1.includes('6870000000000744') || lb1.includes('6870000000000745')) {
            hidden1 = false
        } else {
            hidden1 = true
        }
        mstform.getItem("u_qtxxsm")?.setProps({
            hidden:hidden1
        })
        mstform.getItem("u_bgsptcyjxxsm")?.setProps({
            hidden:hidden,
        })
    }
    function lbMFilter() {

        let label = "变更"
        const val = mstform.getItem("u_bgsj").getValue()
        switch (String(val)) {
            case '03':
                label = '调差'
                break
            case '01':
                label = "变更"
                break
            case '02':
                label = '索赔'
                break
        }
        mstform.getItem("u_bglb").setProps({
            onBeforeOpen: async () => {
                var u_bgsj = getHeadValue("u_bgsj")
                if (!u_bgsj) {
                    $NG.alert("请先选择变更事件！");
                    return false;
                } else {
                    return true;
                }
            },
            clientSqlFilter: {
                c_descript: `${label}类别`,//合同类型
            }
        });
    }

})